def square(x):
	return x*x

def fib_iter(a,b,p,q,n):
    if n==0:
        return b
    else:
        if n%2==0:
            return fib_iter (a,b,square(p)+square(q),(2*p*q+square(q)),n/2)
        else:
            return fib_iter(b*q+a*q+a*p,b*p+a*q,p,q,n-1)
def fib(n):
    return fib_iter(1,0,0,1,n)
term=12
while 1:
    digit=len(str(fib(term)))
    if digit>=1000:
        break
    term+=1
print term
